package console;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;

import money.Money;

public class Console {

	private static int actuallAccountNumber;

	// ### Filereader ###
	public static void filereader(String s_File) throws IOException {
		File f_File = new File(s_File);
		BufferedReader br = new BufferedReader(new FileReader(f_File));
		String s_Line;
		// Walk through the File
		while ((s_Line = br.readLine()) != null) {
			System.out.println(s_Line);
		}
	}

	// ### ConsInput ###
	public static String consInput() {
		String s_Input = "";
		try {
			BufferedReader in = new BufferedReader(new InputStreamReader(
					System.in));
			s_Input = in.readLine().toString();
		} catch (IOException ex) {
			System.err.println("ERROR: WRONG INPUT");
			System.exit(255);
		}
		return s_Input;
	}

	private static Money inputValue() {
		System.out.println("Type the amount of money: ");
		long inputValue = Long.parseLong(consInput()) * 100;
		//inputValue = Money.changeToEuro(inputValue, actuallAccountNumber);
		return new Money(inputValue);
	}

	private static String reason() {
		System.out.println("Type the reason for this action: ");
		String reason = consInput();
		if (reason == null) {
			reason = "No Reason";
		}
		return reason;
	}

	private static String accountName() {
		System.out.println("Type Account Name: ");
		String AccountName = consInput();
		return AccountName;
	}

	private static int accountNumber() {
		System.out.print("Type your account Number: ");
		int AccountNumber = (Integer.parseInt(consInput()));
		setactualAccountNumber(AccountNumber);
		return AccountNumber;
	}

	private static int runtime() {
		System.out.println("Timespan of the Account: ");
		System.out.println("1. for 1 month. 2 for 6 months. 3 for 1 year:");
		int runtime = (Integer.parseInt(consInput()));
		return runtime;
	}

	private static int creditrating() {
		System.out.println("1 for 5, 2 for 10, 3 for 15");
		int creditrating = (Integer.parseInt(consInput()));
		return creditrating;
	}

	private static String language() {
		System.out.println("Type language: ");
		String language = consInput();
		return language;
	}

	private static String country() {
		System.out.println("Type country: ");
		String country = consInput();
		return country;
	}

	/*
	 * ################################################## Getter / Setter
	 * ##################################################
	 */
	public static String getAccountName() {
		String AccountName = accountName();
		return AccountName;
	}

	public static String getReason() {
		String Reason = reason();
		return Reason;
	}

	public static Money getInputValue() {
		Money value = inputValue();
		return value;
	}

	public static int getAccountNumber() {
		int AccountNumber = accountNumber();

		return AccountNumber;
	}

	public static int getruntime() {
		int runtime = runtime();
		return runtime;
	}

	public static int getcreditrating() {
		int creditrating = creditrating();
		return creditrating;
	}

	public static String getlanguage() {
		String language = language();
		return language;
	}

	public static String getcountry() {
		String country = country();
		return country;
	}

	public static void setactualAccountNumber(int newAccountNumber) {
		actuallAccountNumber = newAccountNumber;
	}

	public static int getactualAccountNumber() {
		return actuallAccountNumber;
	}

}
